package net.wofly.common.pay;

import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.io.IOException;

@Service
public abstract class AbstractPayProcessor implements PayProcessor {
    
    @PostConstruct
    public void init() {
        payChannelMap.put(getPayChannel(), this);
    }
    
    @Override
    public PayContext process(PayContext payContext) throws IOException{
        return doPay(payContext);
    }
    
    public abstract PayContext preCheck(PayContext payContext);
    
    public abstract PayContext doPay(PayContext payContext) throws IOException;
    
    public abstract Integer getPayChannel();
}
